﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using DataAnnotationsExtensions;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Models;
using SchoolPointe.Menus.Enums;
using SchoolPointe.Menus.Models;

namespace SchoolPointe.Menus.ViewModels
{
    public class MenuItemContentItemViewModel : MenuItemViewModel
    {        
        public MenuItemContentItemViewModel() : base()
        {
            this.MenuItemType = MenuItemType.ContentItem;            
        }

        public MenuItemContentItemViewModel(BetterMenuItemPart part)
            : base(part)
        {            
            this.MenuItemType = MenuItemType.ContentItem;

            if (part.RelatedItem.Value != null)
            {
                this.ContentItem = part.RelatedItem.Value;
            }
        }

        public IContent ContentItem { get; set; }

        public override void UpdatePart(BetterMenuItemPart part)
        {
            part.Text = Text;
            part.MenuItemType = MenuItemType.ContentItem;
            part.SortOrder = SortOrder;
        }
    }
}